//
//  AllHeroCollectionViewCell.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/19.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "AllHeroCollectionViewCell.h"

@implementation AllHeroCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame
{

    self = [super initWithFrame:frame];
    
    if (self) {
        [self createSubViews];
    }

    return self;
}


-(void)dealloc
{
    [_hero release];
    [_myImageView release];
    [_myLabel release];
    [super dealloc];

}


-(void)createSubViews
{

    self.myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 25)];
    self.myImageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myImageView];
    [_myImageView release];
    
    self.myLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myImageView.frame.origin.x, self.myImageView.frame.origin.y + self.myImageView.frame.size.height, self.myImageView.frame.size.width, 25)];
    self.myLabel.backgroundColor = [UIColor clearColor];
    
    self.myLabel.textAlignment = NSTextAlignmentCenter;
    self.myLabel.font = [UIFont systemFontOfSize:15];
    self.myLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.myLabel];
    [_myLabel release];
    
}

-(void)setHero:(HeroModel *)hero
{

    if (_hero != hero) {
        
        [_hero release];
        _hero = [hero retain];
        
    }

    self.myLabel.text = self.hero.title;

    self.myLabel.lineBreakMode = NSLineBreakByCharWrapping;
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",self.hero.enName]];
    [self.myImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    
    

}



@end
